<template>
    <div class="exam-wrap">
        <div class="main clearfix">
            <mt-radio title="通知范围：" v-model="form.scope" :options="options"></mt-radio>
            <mt-field label="标题：" v-model="form.title" placeholder="请输入通知标题"></mt-field>
            <mt-field label="内容：" v-model="form.content" placeholder="请输入通知内容" type="textarea" rows="4"></mt-field>
        </div>
        <div class="btn-box">
            <mt-button type="danger" @click="cancel" size="large">取消</mt-button>
            <mt-button type="primary" @click="submit" size="large">发布</mt-button>
        </div>
        
    </div>
</template>

<style>
    .main{
        padding: 0px 15px;
    }
    .test-main{
        width: 90%;
    }
    .btn-box{
        text-align: center;
        padding-top: 30px;
    }
    .btn-box button{
        width: 42%;
        display: inline-block;
        margin: 0 2%;
    }
    input[type="text"]:disabled{
        background-color: #fff;
    }
    .mint-popup{
        width: 100%;
    }
    .picker-item{
        text-align: center;
    }
    .sure{
        position: absolute;
        right: 0px;
        background: #fff;
        color: #26a2ff;
        box-shadow: none;
    }
    .cancel{
        position: absolute;
        left: 0px;
        background: #fff;
        color: #26a2ff;
        box-shadow: none;
    }
    .mint-button::after{
        background: #fff;
    }
    input:focus{
        border: none;
    }
    .mint-radiolist-title{
        font-size: 14px;
        color: #666;
    }
</style>



<script>
import conf from '../config/userconf.js'
export default {
    name: 'publishnews',
    data () {
        return {
            form: {
                title: '',
                content: '',
                scope: '1',
            },
            options: [
                {
                    label: '全院',
                    value: '1'
                },
                {
                    label: '本科室',
                    value: '2'
                },
            ],
        }
    },
    methods:{
        submit(data=Object()){
            if(!this.form.title){

                this.$toast('请输入标题');
                return;
            }
            if(!this.form.content){

                this.$toast('请输入内容');
                return;
            }
            
            data = this.form;
            console.log(data);
            conf.exams.noticepublish(data,(state,res)=>{
                if (state == 'success'&&res.data.status == 1){
                    console.log(res.data);

                    this.$toast(res.data.message);
                    
                }else if(state == 'success'&&res.data.status != 1){
                    this.$toast(res.data.message);
                }
            })

        },
        cancel(){
            this.$router.back(-1);
        },
    },
    mounted:function(){
        document.title = "发布通知消息";
    },
}
</script>